<?php

/* Parse values and replace bad characters from form input*/

if ($_POST['plain_text']!="") {
        $plain = preg_split("/[\n]+/", $_POST['plain_text'], -1, PREG_SPLIT_NO_EMPTY);
	array_unshift($plain, $_POST['aed_' . mysql_field_name($result, 0)]);
} else {
	for ($i=0; $i < $fields; $i++) {
	        $name  = mysql_field_name($result, $i);
	        $name = "aed_" . $name;
	        $plain[$i] = $_POST[$name];
	 }
}

/* Replacing bad characters */
for ($i=0; $i < $fields; $i++) {
	$plain[$i] = trim($plain[$i]);
	if ($_POST['Submit'] == 'Add Data' || $_POST['Submit'] == 'Make Copy' || $_POST['Submit'] =='Update Data') {
//echo "<ul><li>". $plain[$i]. "</li>";
//		$plain[$i] = trim($plain[$i]);
		$plain[$i] = mysql_real_escape_string($plain[$i]);
//echo "<li>".$plain[$i]. "</li></ul>";
	}

//	echo "<p>".$plain[$i]."</p>";
//	$plain[$i] = str_replace("\\", "&#92;", $plain[$i]);
//	$plain[$i] = str_replace("'", "&#39;", $plain[$i]);
}
?>
